<%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 2022/1/18
  Time: 14:04
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="common/head.jsp"%>
<script src="../static/js/jquery-3.4.1.js"></script>
<script>
    $(function(){
        $.ajax({
            url:"../user/lookstu",
            data:{},
            type:"post",
            dataType:"json",
            success:function(data){
                // alert(data.stuid)
                // alert(data.stuname)

                $(".leaveid").val(data.stuid)
                $(".leavename").val(data.stuname)
            }
        })

    })
    function leaveForm1() {
        var leave = $(".leaveForm").serializeArray();
        alert(leave[2].value)
        $.ajax({
            url: "../leave/insert",
            data: leave,
            type: "get",
            dataType: "json",
            success: function (data) {
                if (data ==true){
                    alert("添加成功")
                }else{
                    alert("添加失败")
                }

            }
        })
        return false;
    }
</script>
<html>
<head>
    <title>请假申请</title>
</head>
<style>
    table,form{
        margin-left: auto;
        margin-right: auto;
        margin-top: 30px;
    }
</style>
<body>
<%--240,248,255--%>
<form class="leaveForm" name="leaveForm" onsubmit="return leaveForm1()" >
    <table style="width: 500px;height: 250px;background-color: #f0f8ff;" border="1px solid red" cellspacing="0px"  >
        <caption><h2>请假申请</h2></caption>
<%--        <tr >--%>
<%--            <td>编号：</td>--%>
<%--            <td><input class="leaveid" name="leaveid" type="text" readonly ></td>--%>
<%--        </tr>--%>
        <tr>
            <td>请假人：</td>
            <td>
                <input type="text" name="leaveperson" readonly class="leavename">
            </td>
        </tr>
        <tr>
            <td>请假时间：</td>
            <td><input required  type="date" name="leavetime"  class="leavetime" value="<fmt:formatDate value="${estiDetail.discoverTime}" pattern="yyyy-MM-dd" />"  ></td>
        </tr>
        <tr>
            <td>开始时间：</td>
            <td><input required type="date" name="starttime"  class="starttime"></td>
        </tr>
        <tr>
            <td>请假原因：</td>
            <td><textarea required cols="30" rows="5" name="leavereson"  class="leavereason"></textarea></td>
        </tr>
        <tr>
            <td colspan="2">
                <div align="center">
                <input type="submit" value="申请">
                <input type="reset" value="取消">
                </div>
            </td>
        </tr>
    </table>
</form>
<%@include file="common/foot.jsp" %>
</body>
</html>
